//商品刷新功能
create_table = (arr) =>{
    $(".content-box")[0].innerHTML = "";
    let str = "";
    for( let i = 0;i < arr.length;i++ ){
            //获取商品的名称、商品的价格、商品的存储路径
            let o_name = arr[i].pro_name;
            let o_price = arr[i].pro_price;
            let o_imgpath = arr[i].pro_imgpath;
            console.log(o_name);
            console.log(o_price);
            console.log(o_imgpath);
  
            str = `<div>
                          <div><a href=""><img src="${o_imgpath}" alt=""></a></div>
                          <div>
                              <a href="">
                                  <div>${o_name}</div>
                                  <div>${o_price}</div>
                                  <input type="button" value="立即购买">
                              </a>
                              <a href=""><input type="button" value="收藏"></a>
                          </div>
                    </div>`;
                    $(".content-box")[0].innerHTML += str;
    }
  }
  
  
  //刷新页面
  //创建xhr对象
   let xhr = new XMLHttpRequest();
  
   //实现open方法
   xhr.open( "get","./api/get_prodata.php",true );
  
   //发送请求
   xhr.send();
  
   //设置监听状态
   xhr.onreadystatechange = function(){
       if( xhr.readyState === 4 && xhr.status === 200 ){
           let arr = JSON.parse( xhr.responseText );
           console.log( arr );
           create_table( arr );
       }
   }